package com.dl;

import com.dl.service.UserService;
import com.dl.utils.RedisUtils;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.DigestUtils;

import javax.annotation.Resource;
import java.util.Arrays;

@SpringBootTest
@RunWith(SpringRunner.class)
class testMd5 {

    @Resource
    private RedisTemplate<String,Object> redisTemplate;

    @Resource
    private StringRedisTemplate stringRedisTemplate;

    @Resource
    private UserService userService;

    @Resource
    private RedisUtils redisUtils;

    @Test
    public void testTemplate(){
        String key = "-1112671249:1311912646:com.dl.dao.UserMapper.findPermissionsByRolesID:0:2147483647:select\n" +
                "            p.id,p.name,p.url,r.name\n" +
                "        from\n" +
                "            role r\n" +
                "                LEFT JOIN role_permission rp ON rp.roleID = r.id\n" +
                "                LEFT JOIN permission p ON rp.permissionID = p.id\n" +
                "        where\n" +
                "            r.id = ?:2:SqlSessionFactoryBean";

        //使用spring框架提供的工具类
        byte[] bytes = DigestUtils.md5Digest(key.getBytes());
        System.out.println("bytes = " + Arrays.toString(bytes));

        String s = DigestUtils.md5DigestAsHex(key.getBytes());
        System.out.println("s = " + s);


    }

}
